<?php
namespace App\Base\Controllers;

use App\Base\Contracts\PublicInterface;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;


/**
 * Created by 荣耀电竞.
 * User: 林子彦 <278805354@qq.com>
 * Date: 2018/2/6 0006
 * Time: 11:12
 */
class PublicController extends Controller
{
    /**
     * @return PublicInterface
     */
    public function getPublicInterface(){
        return app()->make(PublicInterface::class);
    }
    /**
     * 图片上传
     */
    public function uploadPic(Request $request){
        if ($request->isMethod('post')) {
            $file = $request->file('file');
            // 文件是否上传成功
            if ($file->isValid()) {
                if ($info = $this->getPublicInterface()->savePicture($file)) {
                    $info["src"]=$info["token"];
                    return $info;
                } else {
                    throw  new ApiException([20001,"上传失败."]);
                }
                exit();
            }
        }
    }
    /**
     * 发送手机号
     */
    public function sendMobile(){

    }

}